home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
swtools
/
trubasic
/
rolldemos
/
TIPS
< prev
next >
Wrap
Text File
|
1994-08-02
|
3KB
|
92 lines
When creating a True BASIC UNIX graphics application, enclose the code
in an error handler so that if in the unlikely case that an error occurs
you can print out an informative message:
when error in
call main_event_loop
use
set mode "text"
! error message diagnostics
print extext$,extype,exline$
end when
Otherwise when an error occurs, the window will close and the program will
end. You can also use the routine SUB PIPE to print messages to stdout.
If the program returns to "graphics" mode, do not use the set mode "text"
statement since this will alter the margin and max cursor settings.
Use the PIPE subroutine instead.
-------------------------------------------------------------------------------
Remember that when the program ends the graphics window closes. Use:
GET KEY k
to wait for a key stroke at the end of your program. If you want to respond
to REFRESH events, use the statments:
IF CHECK KEY INPUT THEN
...
END IF
IF REFRESH(1)=1 THEN
! your routine to refresh the screen
call refresh_screen
END IF
to check for input without blocking and to handle refresh/redraw events.
-------------------------------------------------------------------------------
A summary of commands can be found in "./cmdlist" with the corresponding
man pages in "./manpp". To display a manpage, either copy the files in
"./manpp" to "usr/catman/local/cat1" and type:
man <cmd>
or move to the "./manpp" directory and type:
man -d <cmd.z>
where <cmd.z> is any of the files in the directory.
-------------------------------------------------------------------------------
Passing channel numbers to subroutines:
Channel numbers consist of the #<number> sequences in OPEN statements for
windows and files.
Subroutines may have channel numbers as parameters. Functions may not.
For example,
SUB openfile (qu$, #1) ! open a file
PRINT qu$; ! prompt user
INPUT f$ ! name of file
CLOSE #1 ! in case #1 is open
OPEN #1: name f$
END SUB
CALL openfile("data file", #3) ! invoke it
The file just opened becomes #3 in the calling program. In this manner,
you may use one subroutine to open different files.
WARNING: it is possible to use a variable as the channel number but you
may get the message "System error - margin <=0" or other related messages
about the channel not being open. It is suggested that the method in the
example be used to avoid problems.
-------------------------------------------------------------------------------
When you create a stand-alone executable, you get everything from matrix
operations to the Graphics Libaries. For most programs the compile time
is negligible and it is more practical to run programs from source.
Larger programs will be comparable in size with programs written in languages
such as C which optimize the code to a greater extent.
-------------------------------------------------------------------------------